-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[MLIR][IRDL][CMake] CMake fixes for cross-compilation #145672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-mlir Author: None (arthurqiu) ChangesThe PR fixes a misconfigured dependency that causes CMake error "No rule to make target 'NATIVE/bin/mlir-irdl-to-cpp'" for cross-compilation. Full diff: https://github.com/llvm/llvm-project/pull/145672.diff 1 Files Affected:
diff --git a/mlir/cmake/modules/IRDLToCpp.cmake b/mlir/cmake/modules/IRDLToCpp.cmake
index 8470ccdf55166..2457773ef2565 100644
--- a/mlir/cmake/modules/IRDLToCpp.cmake
+++ b/mlir/cmake/modules/IRDLToCpp.cmake
@@ -5,7 +5,7 @@ function(add_irdl_to_cpp_target target irdl_file)
# The command output depends on the executable to ensure IRDL sources are properly rebuilt
# if the tool changes.
- DEPENDS ${MLIR_IRDL_TO_CPP_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/${irdl_file}
+ DEPENDS ${MLIR_IRDL_TO_CPP_TARGET} ${CMAKE_CURRENT_SOURCE_DIR}/${irdl_file}
COMMENT "Building ${irdl_file}..."
)
add_custom_target(${target} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${irdl_file}.cpp.inc)
|
|
@Moxinilian request for review. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you checked the comment above? Can you make sure that it still correctly rebuilds the sources if the tool changes? If this is not the case you may want to depend on both the target and the executable.
Not sure if I miss anything, but I think IRDL source should still be rebuilt if it depends on https://cmake.org/cmake/help/latest/command/add_custom_command.html
|
|
Could you please try? This is what I did the first time and it did not work. In parallel I am asking for help on the Discord server. It would be nice if there was a way to test the build system for this property automatically somehow, but this seems tricky to set up. |
|
I'm not 100% sure on what's going on here but generally these tools are referred to by llvm-project/mlir/tools/mlir-linalg-ods-gen/CMakeLists.txt Lines 7 to 17 in e9c9f8f
Looking at mlir-irdl-to-cpp/CMakeLists.txt I see someone tried to maybe do the same thing?? but didn't quite nail it? Then again I'm not sure what the intent for this tool is. But certainly if you want |
|
Hmm looking at the custom command for llvm-project/mlir/include/mlir/Dialect/Linalg/IR/CMakeLists.txt Lines 14 to 18 in e9c9f8f
Okay in the case maybe this is kosher - although that CMake for the tool itself is still fishy but 🤷. |
|
This tool behaves exactly like mlir-tblgen (in fact it serves the same purpose). So it should be built on the host platform, not on the target platform. I also understood it should be referenced via EXE as it is obtained from the NATIVE build. So the problem seems to be that in your environment @arthurqiu it is not able to find how to build it? I had tried before that it works while cross-compiling and it did. Are you sure your environment is correctly configured? In any case it should work no matter what, so I’d like to know what failed in your set up. |
|
Also maybe I just misremember what I did at the time and this works for incremental rebuilds if the tool change. I can verify it does if you don’t have time but I don’t have much time either right now so it may take a bit. |
|
I have reproduced the problem I was referring to with this patch applied. But the good news is that I also tried having the target depend on both |
f872c41 to
24e5428
Compare
24e5428 to
4ab2b9a
Compare
It works for me. And this explains why we need both: llvm-project/mlir/cmake/modules/AddMLIR.cmake Lines 92 to 100 in 7e3e2e1
|
|
Well it seems like I can’t accept now that I merged it. Anyway, thanks for the fix! |
The PR fixes a misconfigured dependency that causes CMake error "No rule to make target 'NATIVE/bin/mlir-irdl-to-cpp'" for cross-compilation.